<template>
  <div class="Partners">
    <!-- <div class="header">{{ headtitle }}</div> -->
    <div class="header">合作机构</div>
    <div class="contentFirst" style="padding-top:20px;">
      <a-steps :current="getCurrentStep()">
        <a-step v-if="!videoLoad" title="信息填写" description />
        <a-step
          v-if="videoLoad"
          style="cursor: pointer;"
          @click="goPage(1)"
          title="信息填写"
          description="点击修改"
        />
        <a-step v-if="!videoLoad2" title="资料上传" description />
        <a-step
          v-if="videoLoad2"
          style="cursor: pointer;"
          @click="goPage(2)"
          title="资料上传"
          description="点击修改"
        />
        <a-step title="业务配置" description />
        <a-step title="资料审核" description />
      </a-steps>
    </div>
    <!-- <div class="contentFirst">
      <a-steps :initial='4' :current="getCurrentStepFromFive()">
        <a-step title="资料上传" description />
        <a-step title="业务配置" description />
        <a-step title="资料审核" description />
      </a-steps>
    </div>-->
    <div class="content">
      <div style="height: 30px; width:100%;"></div>
      <router-view :key="key" />
    </div>
  </div>
</template>
<script>
export default {
  //  components: {
  //      ASteps,
  //     "a-step":ASteps.Step
  // }
  data() {
    return {
      headtitle: "",
      picLoad: false,
      videoLoad: false,
      videoLoad2: false,
      lasttitle: "",
    };
  },
  computed: {
    key() {
      return this.$route.path + Math.random();
    },
  },
  watch: {
    $route(to, from) {
      console.log(to.path);
      let step = to.path.split("/");

      let end = step[step.length - 1];
      let endnumber = end.split("step");

      let stepnumber = Number(endnumber[1]);

      console.log(stepnumber);
      if (stepnumber == 1) {
        console.log("路由地址1");
        this.videoLoad = false;
        this.videoLoad2 = false;
      } else if (stepnumber == 2) {
        console.log("路由地址2");
        this.videoLoad = true;
        
        this.videoLoad2 = false;
        console.log(this.videoLoad);
        console.log(this.videoLoad2);
      } else if (stepnumber == 3) {
        console.log("路由地址3");
        this.videoLoad = true;
        this.videoLoad2 = true;
      }
    },
  },
  created() {
    // this.lasttitle =
  },
  methods: {
    goPage(st) {
      let urltype = localStorage.getItem("urlType");
      let queryid = localStorage.getItem("queryid");
      if (urltype == "PartnersAdmin") {
        if (st == 1) {
          this.$router.push({
            name: "合作机构新增(超级管理员)",
            params: {
              queryid: queryid ? queryid : null,
            },
          });
        } else if (st == 2) {
          this.$router.push({
            name: "/Partners/dataUploadA/step2",
            params: {
              admin: true,
              isPrivate: sessionStorage.getItem("isPrivate"),
              queryid: queryid ? queryid : null,
            },
          });
        }
      }

      if (urltype == "userTypeA") {
        if (st == 1) {
          this.$router.push({
            name: "/Partners/userTypeA/step1",
            params: {
              queryid: queryid ? queryid : null,
            },
          });
        } else if (st == 2) {
          this.$router.push({
            name: "/Partners/dataUploadA/step2",
            params: {
              isPrivate: sessionStorage.getItem("isPrivate"),
              queryid: queryid ? queryid : null,
            },
          });
        }
      }

      if (urltype == "userTypeB") {
        if (st == 1) {
          this.$router.push({
            name: "/Partners/userTypeB/step1",
            params: {
              queryid: queryid ? queryid : null,
            },
          });
        } else if (st == 2) {
          this.$router.push({
            name: "/Partners/dataUploadB/step2",
            params: {
              isPrivate: true,
              queryid: queryid ? queryid : null,
            },
          });
        }
      }
    },
    getCurrentStep(e) {
      const pathname = this.$route.path;
      const pathList = pathname.split("/");
      var step = pathList[pathList.length - 1];
      if (step && step.indexOf("step") >= 0) {
        let s = step.replace("step", "");
        if (s) {
          return parseInt(s) - 1;
        }
      }
      return 0;
    },
    getCurrentStepFromFive(e) {
      // console.log(this.$route.path)
      const pathname = this.$route.path;
      const pathList = pathname.split("/");
      const pathnameList = pathname.split("");
      // console.log(pathList)
      // console.log(pathnameList)
      // console.log("pathnameList[pathnameList.length-1]",pathnameList[pathnameList.length-1]);
      // console.log("pathnameList[pathnameList.length-1]",typeof pathnameList[pathnameList.length-1]);
      switch (pathnameList[pathnameList.length - 1]) {
        case "6":
          this.headtitle = "认证视频";
          break;
        case "7":
          this.headtitle = "资料上传";
          break;
        case "8":
          this.headtitle = "资料审核";
          break;
        case "9":
          this.headtitle = "打款验证";
          break;
        case "10":
          this.headtitle = "完成";
          break;
      }
      var step = pathList[pathList.length - 1];
      if (step && step.indexOf("step") >= 0) {
        let s = step.replace("step", "");
        // console.log('s', s)
        if (s) {
          // console.log('parseInt(s) - 1', parseInt(s) - 1)
          return parseInt(s) - 1;
        }
      }
      return 0;
    },
  },
};
</script>
<style scoped>
.header {
  padding: 10px;
  text-align: center;
  font-weight: 500;
  color: #ffffff;
  font-size: 16px;
  background: #b3292c;
}

.contentFirst {
  width: 90%;
  margin: 0 auto;
  padding: 10px;
}

.content {
  width: 90%;
  margin: 0 auto;
  padding: 10px;
}
.Partners {
  overflow: scroll;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
/*滚动条样式*/
.Partners::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 4px;
  /*高宽分别对应横竖滚动条的尺寸*/
  height: 4px;
}

.Partners::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  border-radius: 5px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.2);
}

.Partners::-webkit-scrollbar-track {
  /*滚动条里面轨道*/
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.1);
}
/* .ant-steps {
    display: table-cell;
  } */

/* .ant-steps-item {
    width: 200px;
    margin-top: 10px;
    flex: auto;
    -webkit-box-flex: inherit;
    overflow: hidden;
  }

  .ant-steps-item-tail {
    background-color: red;
  } */
</style>